<%=render 'layouts/header'%>

<div class="container user new">
  <%=render 'comoms/alert'%>
  <%=form_for @user, html:{class:"app_form"} do |f|%>
    <div class="title">
      <span>
        <% if @user.persisted? %>
          修改用户
        <% else %>
          新建用户
        <% end %>
      </span>
    </div>
      <% unless @init_admin %>
        <div class="form-group">
          <label for="plat_name">类型：</label>
          <%=f.select(:role,{'普通用户'=>'user','管理员'=>'admin'},{},{class:"form-control"}) %>
        </div>
      <% else %>
        <%= hidden_field_tag "user[role]", 'admin' %>
      <% end %>
      <div class="form-group">
        <label for="app_name">邮箱：</label>
        <%= f.text_field :email, class:"form-control", required:true %>
      </div>
      <div class="form-group">
        <label for="app_name">密码：</label>
        <%= f.password_field :password, class:"form-control", required:true %>
      </div>
      
    <%=f.submit @user.persisted? ? "保存" : "新建", class:"btn btn-primary ui-plat"%>
  <%end%>
</div>